<%@ include file="includeTop.jsp"%>
<html>
<head>
<title></title>
<%@ include file="includeTop_head.jsp"%>
</head>
<body>
<table height="100" width="100%" align="center"
	style="padding: 0; margin: 0" border=0>
	<tr>
		<td colspan="3"><%@ include file="user_status.jsp"%></td>
	</tr>

	<tr class="title">
		<td><%@ include file="title.jsp"%></td>
		<td align="center"><%@ include file="cartbar.jsp"%></td>
	</tr>
	<tr>
		<td colspan="3" height="70%">
		<table border=0 style="padding: 0; margin: 0">
			<tr>
				<td width="197" valign="top"><%@ include file="admin_left.jsp"%></td>
				<Td width="30"></Td>
				<td width="80%" valign="top">
				<table class="addresssub" id="cart" width="80%" height="300"
					cellspacing="0" cellpadding="0">
					<tr>
						<th height="20">Manage Category</Th>
					</tr>
					<tr><Td><font color="red"><c:out value="${msg}" /></font></Td></tr>
					<tr>
						<td valign="top">
						<table class="product" border="1">
							<tr>
								<th>Category ID</th>
								<th>Parent</th>
								<th>Category Name</th>
								<th>Order</th>
								<th></th>
							</tr>
							<c:forEach var="category" items="${categories}">
								<tr>
									<form id="form_<c:out value="${category.id}" />"
										action="<c:url value="/admin/savecategory.do"/>" method="post"><input
										type="hidden" name="category.id"
										value="<c:out value="${category.id}"/>" /><input
										type="hidden" name="category.categoryId" value="0" />
									<td align="center"><c:out value="${category.id}" /></td>
									<td></td>
									<td><input type="text" name="category.name"
										value="<c:out value="${category.name}"/>" /></td>
									<td><input type="text" name="category.order"
										value="<c:out value="${category.order}"/>" /></td>
									<td width="200" align="center"><input name="type"
										type="submit" value="Update" /><input name="type"
										type="submit" value="Delete" /></td>
									</form>
								</tr>
								<c:if test="${!empty category.childrenCategories}">
									<c:forEach var="category1"
										items="${category.childrenCategories}">
										<tr>
											<form id="form_<c:out value="${category.id}" />"
												action="<c:url value="/admin/savecategory.do"/>"
												method="post"><input type="hidden" name="category.id"
												value="<c:out value="${category1.id}"/>" />
											<td align="center"><c:out value="${category1.id}" /></td>
											<td><select name="category.categoryId">
												<c:forEach var="pcategory" items="${categories}">
													<option
														<c:if test="${pcategory.id == category.id}">selected</c:if>
														value="<c:out value="${pcategory.id}"/>"><c:out
														value="${pcategory.name}" /></option>
												</c:forEach>
											</select></td>
											<td><input type="text" name="category.name"
												value="<c:out value="${category1.name}"/>" /></td>
											<td><input type="text" name="category.order"
												value="<c:out value="${category1.order}"/>" /></td>
											<td align="center"><input name="type" type="submit"
												value="Update" /><input name="type" type="submit"
												value="Delete" /></td>
											</form>
										</tr>
									</c:forEach>
								</c:if>
							</c:forEach>
							<tr>
								<form id="form_add"
									action="<c:url value="/admin/savecategory.do"/>" method="post"><input
									type="hidden" name="category.id" value="0" />
								<td align="center"><c:out value="${category1.id}" /></td>
								<td><select name="category.categoryId">
									<option value="0">Top Level - No Parent</option>
									<c:if test="${!empty categories}">
										<c:forEach var="pcategory" items="${categories}">
											<option
												<c:if test="${pcategory.id == category.id}">selected</c:if>
												value="<c:out value="${pcategory.id}"/>"><c:out
												value="${pcategory.name}" /></option>
										</c:forEach>

									</c:if>
								</select></td>
								<td><input type="text" name="category.name"
									value="<c:out value="${category1.name}"/>" /></td>
								<td><input type="text" name="category.order"
									value="<c:out value="${category.order}"/>" /></td>
								<td align="center"><input name="type" type="submit"
									value="Add Category" /></td>
								</form>
							</tr>
						</table>
						</td>
					</tr>
					<tr>
						<td></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td colspan="3"><%@ include file="includeBottom.jsp"%></td>
			</tr>
		</table>
</body>
</html>
